/*
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.omesoft.hksnore.util.ble;



/**
 *
 *
 * @author omesoft_lgc
 *
 * @date 2015-9-25 下午3:52:06
 */
public class SampleGattAttributes {
	public static String SeviceIDfbb0 = "6e400001-b5a3-f393-e0a9-e50e24dcca9e";
	public static String GetCharacteristicIDfbb1 = "6e400003-b5a3-f393-e0a9-e50e24dcca9e";
	public static String GetCharacteristicIDfbb3 = "6e400002-b5a3-f393-e0a9-e50e24dcca9e";
	public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";

	/**
	 * 匹配蓝牙
	 *
	 * @param deviceName
	 * @return
	 */
	public static boolean isEqualName(String deviceName) {
		if (deviceName.equals("HP_PILLOW") || deviceName.equals("HPM_ZZ")) {

			return true;
		}

		return false;

	}

	/**
	 * 查询音频模块状态
	 *
	 * @param mBluetoothLeService
	 */
	public static void queryAudioModuleState(BluetoothLeService mBluetoothLeService) {
		if (mBluetoothLeService != null) {

			byte[] data = { (byte) 0x55, (byte) 0xAA, 0x05, 0x01, 0x01 };
			mBluetoothLeService.writeCharacteristic(data);
		}
	}

	/**
	 * 查询加速度数据
	 *
	 * @param mBluetoothLeService
	 */
	public static void queryAccelerationData(BluetoothLeService mBluetoothLeService) {
		if (mBluetoothLeService != null) {
			byte[] data = { (byte) 0x55, (byte) 0xAA, 0x01, 0x01, 0x01 };
			mBluetoothLeService.writeCharacteristic(data);
		}
	}

	/**
	 * 振子控制 type 0代表关，1代表开
	 *
	 * @param mBluetoothLeService
	 */
	public static void vbControl(BluetoothLeService mBluetoothLeService, int type) {
		if (mBluetoothLeService != null) {
			if (type == 0) {
				byte[] data = { (byte) 0x55, (byte) 0xAA, 0x03, 0x01, 0x00 };
				mBluetoothLeService.writeCharacteristic(data);
			} else {
				byte[] data = { (byte) 0x55, (byte) 0xAA, 0x03, 0x01, 0x01 };
				mBluetoothLeService.writeCharacteristic(data);
			}
		}
	}

	/**
	 * 查询电池状态
	 *
	 * @param mBluetoothLeService
	 */
	public static void queryBatteryStatus(BluetoothLeService mBluetoothLeService) {

		if (mBluetoothLeService != null) {
			byte[] data = { (byte) 0x55, (byte) 0xAA, 0x04, 0x01, 0x01 };
			mBluetoothLeService.writeCharacteristic(data);
		}
	}

	/**
	 * 控制音频模块 type 0x00: 关闭音频模块 0x01: 启动音频模块 0x02: 增加音量 0x03: 减少音量
	 *
	 * @param mBluetoothLeService
	 */
	public static void controlAudioModule(BluetoothLeService mBluetoothLeService, int type) {
		if (mBluetoothLeService != null) {
			if (type == 0) {
				byte[] data = { (byte) 0x55, (byte) 0xAA, 0x06, 0x01, 0x00 };
				mBluetoothLeService.writeCharacteristic(data);
			} else if (type == 1) {
				byte[] data = { (byte) 0x55, (byte) 0xAA, 0x06, 0x01, 0x01 };
				mBluetoothLeService.writeCharacteristic(data);
			} else if (type == 2) {
				byte[] data = { (byte) 0x55, (byte) 0xAA, 0x06, 0x01, 0x02 };
				mBluetoothLeService.writeCharacteristic(data);
			} else if (type == 3) {
				byte[] data = { (byte) 0x55, (byte) 0xAA, 0x06, 0x01, 0x03 };
				mBluetoothLeService.writeCharacteristic(data);
			}
		}
	}
}
